package com.tencent.sr.iris.activity.common.util;

import org.apache.commons.lang.StringUtils;

/**
 * @author keyonyzhang
 * @date 2022/5/23
 */
public class ExceptionUtils {

    public static String toString(Throwable e) {
        String stackTraceStr = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e);

        // 方便es查看，不要换行
        if (StringUtils.isNotEmpty(stackTraceStr)) {
            stackTraceStr = stackTraceStr.replace("\n", "\t");
        }

        return stackTraceStr;
    }

    public static void main(String[] args) {
        String a = "a\nb";
        System.out.println(a);
        System.out.println(a.replace("\n", "\t"));
    }
}
